<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="security"%>

<script type="text/javascript">
	var user_id;
    // 	$(function()
    //     {
    // 	    $("#delete").click(
    // 	            function()
    // 	            {
    // 		            alert("删除!!!");
    // 		            $.ajax(
    // 		            {
    // 		                url : $(this).attr("href"), type : 'DELETE',
    // 		                success : function(result)
    // 		                {
    // 			                alert(result);
    // 		                }
    // 		            });
    // 		            window.location.reload();
    // 		            return false;
    // 	            });
    //     });
    $ (function ( )
    {
	    //$('table tr:not(:first)').remove();
	    var len = $ ('table tr').length;
	    for (var i = 1; i < len; i++)
	    {
		    $ ('table tr:eq(' + i + ') td:first').text (i);
	    }
    });
    
    function setval (data)
    {
	    user_id = data
	    return false;
    }

    function delete1 ( )
    {
	    var href = ("/users/" + user_id);
	    $ ("#DELETE").attr ("action",href).submit ( );
	    flash_jsp ('/showUsers');
	    return false;
    };
</script>

<div class="btn-toolbar">
	<button class="btn btn-primary" onclick="flash_jsp('/newUser');">
		<i class="icon-plus"> 新 用 户</i>
	</button>
	<button class="btn">全 选</button>
	<button class="btn">清 除</button>
	<button class="btn">删 除</button>
	<div class="btn-group"></div>
</div>
${pageContext.request.contextPath }
<form id="DELETE" action="" method="POST">
	<input type="hidden" name="_method" value="DELETE" />
</form>
<c:if test="${empty requestScope.users }">
		没有任何员工信息.
	</c:if>
<c:if test="${!empty requestScope.users }">
	<table class="table table-bordered table-hover">
		<thead>
			<tr class="custrom-color">
				<td>序号</td>
				<th>用户 ID</th>
				<th>用 户 名</th>
				<th>密 码</th>
				<th>状 态</th>
				<th>权 限</th>
				<th>编 辑</th>
				<th>删 除</th>
			</tr>
		</thead>

		<c:forEach items="${requestScope.users }" var="user">
			<tbody>
				<tr>
					<td></td>
					<td>${user.id }</td>
					<td>${user.username }</td>
					<td>${user.password }</td>
					<td>${user.status == 0 ? 'locked' : 'normal' }</td>
					<td>${user.descn }</td>
					<td><a id="" href="#" onclick="flash_jsp('/users/${user.id}');"><i class="icon-pencil" ></i></a></td>
					<td><a id="" href="#myModal" onclick="setval ('${user.id}')" role="button"
						data-toggle="modal"><i class="icon-trash" ></i></a></td>
				</tr>
			</tbody>
		</c:forEach>
	</table>

	<div class="pagination">
		<ul>
			<li class="disabled"><a href="#">Prev</a></li>
			<li class="disabled"><a href="#">1</a></li>
			<li><a href="#">2</a></li>
			<li><a href="#">3</a></li>
			<li><a href="#">4</a></li>
			<li><a href="#">5</a></li>
			<li><a href="#">Next</a></li>
		</ul>
	</div>
</c:if>
<br>

<div class="modal small hide fade" id="myModal" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
		<h3 id="myModalLabel">消 息</h3>
	</div>
	<div class="modal-body">
		<p class="error-text">
			<i class="icon-warning-sign modal-icon" ></i>真的要删除该用户吗？
		</p>
	</div>
	<div class="modal-footer">
		<button class="btn" data-dismiss="modal" aria-hidden="true">取 消</button>
		<button class="btn btn-primary" data-dismiss="modal" onclick="delete1 ( );">确 定</button>
	</div>
</div>